//
//  SLAppDelegate.m
//  SLBSMainKit
//
//  Created by CoderSLZeng on 11/22/2017.
//  Copyright (c) 2017 CoderSLZeng. All rights reserved.
//

/*
 1.广告业务逻辑
 2.占位视图思想:有个控件不确定尺寸,但是层次结构已经确定,就可以使用占位视图思想
 3.屏幕适配.通过屏幕高度判断
 */

#define code2 @"phcqnauGuHYkFMRquANhmgN_IauBThfqmgKsUARhIWdGULPxnz3vndtkQW08nau_I1Y1P1Rhmhwz5Hb8nBuL5HDknWRhTA_qmvqVQhGGUhI_py4MQhF1TvChmgKY5H6hmyPW5RFRHzuET1dGULnhuAN85HchUy7s5HDhIywGujY3P1n3mWb1PvDLnvF-Pyf4mHR4nyRvmWPBmhwBPjcLPyfsPHT3uWm4FMPLpHYkFh7sTA-b5yRzPj6sPvRdFhPdTWYsFMKzuykEmyfqnauGuAu95Rnsnbfknbm1QHnkwW6VPjujnBdKfWD1QHnsnbRsnHwKfYwAwiu9mLfqHbD_H70hTv6qnHn1PauVmynqnjclnj0lnj0lnj0lnj0lnj0hThYqniuVujYkFhkC5HRvnB3dFh7spyfqnW0srj64nBu9TjYsFMub5HDhTZFEujdzTLK_mgPCFMP85Rnsnbfknbm1QHnkwW6VPjujnBdKfWD1QHnsnbRsnHwKfYwAwiuBnHfdnjD4rjnvPWYkFh7sTZu-TWY1QW68nBuWUHYdnHchIAYqPHDzFhqsmyPGIZbqniuYThuYTjd1uAVxnz3vnzu9IjYzFh6qP1RsFMws5y-fpAq8uHT_nBuYmycqnau1IjYkPjRsnHb3n1mvnHDkQWD4niuVmybqniu1uy3qwD-HQDFKHakHHNn_HR7fQ7uDQ7PcHzkHiR3_RYqNQD7jfzkPiRn_wdKHQDP5HikPfRb_fNc_NbwPQDdRHzkDiNchTvwW5HnvPj0zQWndnHRvnBsdPWb4ri3kPW0kPHmhmLnqPH6LP1ndm1-WPyDvnHKBrAw9nju9PHIhmH9WmH6zrjRhTv7_5iu85HDhTvd15HDhTLTqP1RsFh4ETjYYPW0sPzuVuyYqn1mYnjc8nWbvrjTdQjRvrHb4QWDvnjDdPBuk5yRzPj6sPvRdgvPsTBu_my4bTvP9TARqnam"

#import "SLAppDelegate.h"
#import "Base.h"
#import "SLTestVC.h"
#import "SLMediatorManager+SLMain.h"

@implementation SLAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // 创建窗口
    self.window = [[UIWindow alloc] init];
    self.window.frame = [UIScreen mainScreen].bounds;
    
    UIViewController *rootVC = [SLMediatorManager rootViewController];

    // 设置启动图片
    [self setupLaunchImage];
    
    // 加载广告数据
    [self loadAdData];
    
    // 设置导航栏背景颜色
    [SLMediatorManager setNavBarGlobalBackGroundImage:[UIImage imageNamed:@"navigationbarBackgroundWhite.png"]];
    
    // 设置子控制器
    [self setupChildVCs];
    
    // 设置根控制器
    self.window.rootViewController = rootVC;
    // 显示窗口
    [self.window makeKeyAndVisible];

    // 添加一个最高级别的顶层
    [SLMediatorManager showTopWindow];

    [SLMediatorManager setTabbarMiddleBtnClick:^{
        NSLog(@"点击了中间按钮");
    }];
    return YES;
}

// 6p:LaunchImage-800-Portrait-736h@3x.png
// 6:LaunchImage-800-667h@2x.png
// 5:LaunchImage-568h@2x.png
// 4s:LaunchImage@2x.png
- (void)setupLaunchImage
{
    NSString *imageName;
    
    if (kInch5_5) { // 6p
        imageName = @"LaunchImage-800-Portrait-736h";
    } else if (kInch4_7) { // 6
        imageName = @"LaunchImage-800-667h";
    } else if (kInch4) { // 5
        imageName = @"LaunchImage-568h";
    } else if (kInch3_5) { // 4
        imageName = @"LaunchImage";
    }
    
    if (imageName.length) {
        [SLMediatorManager setupLaunchImageWithImageNamed:imageName];
    }
    
}

- (void)loadAdData
{
//    NSString *urlString = @"http://mobads.baidu.com/cpro/ui/mads.php";
    NSString *urlString = @"";
    NSMutableDictionary *paramDict = [NSMutableDictionary dictionary];
    paramDict[@"code2"] = code2;
    [SLMediatorManager loadAdDataWithRequestURLString:urlString Parameters:paramDict];

}


- (void)setupChildVCs
{
    // 精华
    [SLMediatorManager addChildVC:[[SLTestVC alloc] init]
                            title:@"精华"
                  normalImageName:@"tabBar_essence_icon"
                selectedImageName:@"tabBar_essence_click_icon"
          isRequiredNavController:YES];

    // 新帖
    [SLMediatorManager addChildVC:[[SLTestVC alloc] init]
                        title:@"新帖"
              normalImageName:@"tabBar_new_icon"
            selectedImageName:@"tabBar_new_click_icon"
      isRequiredNavController:YES];

    // 关注
    [SLMediatorManager addChildVC:[[SLTestVC alloc] init]
                        title:@"关注"
              normalImageName:@"tabBar_friendTrends_icon"
            selectedImageName:@"tabBar_friendTrends_click_icon"
      isRequiredNavController:YES];

    // 我
    [SLMediatorManager addChildVC:[[SLTestVC alloc] init]
                        title:@"我"
              normalImageName:@"tabBar_me_icon"
            selectedImageName:@"tabBar_me_click_icon"
      isRequiredNavController:YES];
}


@end
